package com.solocredit.finance.ui.loan.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.solocredit.finance.R
import com.solocredit.finance.base.adapter.MullaRecyclerViewAdapter
import com.solocredit.finance.base.adapter.MullaViewHolderHelper
import org.json.JSONObject

/**
 * MullaFlow
 * @Author wwdeng
 * @CreateTime: 2024/8/5 14:42
 * @Annotation：贷款申请 选择时间 适配器
 */
class MullaLoanApplyDaysAdapter(recyclerView: RecyclerView?) : MullaRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_mulla_loan_apply_days) {
    override fun setItemChildListener(helper: MullaViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.textDays) //点击Item
    }

    override fun fillData(helper: MullaViewHolderHelper, position: Int, model: JSONObject) {
        val textDays = helper.getTextView(R.id.textDays)
        textDays.text = model.optString("day")

        if (model.optBoolean("isEnabled",true)){//可选
            if (model.optBoolean("isSelect",false)){
                textDays.setBackgroundResource(R.drawable.mulla_radius_frame_ffd21034_12_w2)
                textDays.setTextColor(Color.parseColor("#FFD21034"))
            } else {
                textDays.setBackgroundResource(R.drawable.mulla_radius_fill_ffe7e7e7_12)
                textDays.setTextColor(Color.parseColor("#FFFFFFFF"))
            }
        } else {//不可选
            textDays.setBackgroundResource(R.drawable.mulla_radius_fill_ffdedede_12)
            textDays.setTextColor(Color.parseColor("#FFFFFFFF"))
        }
    }
}